// pages/test/test.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    openid:"",
    webUrl:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    if (options.webUrl!=undefined){
      if (options.webUrl=='aRed'){
        this.setData({
          webUrl: "https://t.gxmp.henghi.com/api/squan/initauth?version=1.5.8&webUrl=" + options.webUrl + "&zf_openid=" + options.zf_openid + '&redId=' + options.redId
        })
        console.log(options)
      } else if (options.webUrl == 'wrq'){
        this.setData({
          webUrl: "https://t.gxmp.henghi.com/api/squan/initauth?version=1.5.8&webUrl=" + options.webUrl + "&zf_openid=" + options.zf_openid + '&wrqid=' + options.wrqid
        })
      } else if (options.webUrl == 'shop_index'){
        this.setData({
          webUrl: "https://t.gxmp.henghi.com/api/squan/initauth?version=1.5.8&webUrl=" + options.webUrl + "&zf_openid=" + options.zf_openid + '&share_user_id=' + options.share_user_id
        })
      } else if (options.webUrl == 'goods_detail') {
        this.setData({
          webUrl: "https://t.gxmp.henghi.com/api/squan/initauth?version=1.5.8&webUrl=" + options.webUrl + "&zf_openid=" + options.zf_openid + '&share_user_id=' + options.share_user_id + "&goods_id=" + options.goods_id
        })
      }else{
        this.setData({
          webUrl: "https://t.gxmp.henghi.com/api/squan/initauth?version=1.5.8&webUrl=" + options.webUrl + "&zf_openid=" + options.zf_openid + '&roomID=' + options.roomID
        })
      }
    } else if (options.scene != undefined){
      var scene = decodeURIComponent(options.scene);
      var user_id = scene.split("_")[0];
      var weburl = scene.split("_")[1];
      var id = scene.split("_")[2];
      if (weburl == 'aRed') {
        this.setData({
          webUrl: "https://t.gxmp.henghi.com/api/squan/initauth?version=1.5.8&webUrl=" + weburl + "&zf_openid=scene&uid=" + user_id + '&redId=' + id
        })
      } else {
        this.setData({
          webUrl: "https://t.gxmp.henghi.com/api/squan/initauth?version=1.5.8&webUrl=" + weburl + "&zf_openid=scene&uid=" + user_id + '&roomID=' + id
        })
      }
    }else{
      this.setData({
        webUrl: "https://t.gxmp.henghi.com/api/squan/initauth?version=1.5.8"
      })
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },
  bindGetMsg:function(e){
    // JSON.parse()
    console.log(e)
    var userInfo = e.detail.data[0] 
    console.log(userInfo)
    wx.setStorageSync('userInfo', userInfo);
    wx.setStorageSync('token__', userInfo.token)
    wx.setStorageSync('token_key', userInfo.token_key)
    getApp().globalData.userInfo = userInfo
    getApp().globalData.openid = userInfo.openid
    getApp().globalData.unionid = userInfo.unionid
    getApp().globalData.uniq_openid = userInfo.uniq_openid
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})